package com.eshunda.eshunda_android_demo;

import android.content.Intent;
import android.os.Bundle;
import android.view.View;
import android.widget.Toast;

import androidx.appcompat.app.AppCompatActivity;

import com.google.android.material.card.MaterialCardView;

/**
 * 应用主页 - 产品选择页面
 * 提供活体检测、实人认证、人脸认证1:1三个产品入口
 */
public class MainActivity extends AppCompatActivity implements View.OnClickListener {
    
    private static final String TAG = "MainActivity";
    
    private MaterialCardView cardLivingDetect;
    private MaterialCardView cardRealPersonAuth;
    private MaterialCardView cardFaceCompare;

    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.activity_home);
        
        initViews();
    }
    
    /**
     * 初始化视图组件
     */
    private void initViews() {
        cardLivingDetect = findViewById(R.id.card_living_detect);
        cardRealPersonAuth = findViewById(R.id.card_real_person_auth);
        cardFaceCompare = findViewById(R.id.card_face_compare);
        
        // 设置点击监听
        cardLivingDetect.setOnClickListener(this);
        cardRealPersonAuth.setOnClickListener(this);
        cardFaceCompare.setOnClickListener(this);
    }

    @Override
    public void onClick(View v) {
        int viewId = v.getId();
        
        if (viewId == R.id.card_living_detect) {
            // 跳转到活体检测页面
            startLivingDetect();
        } else if (viewId == R.id.card_real_person_auth) {
            // 跳转到实人认证页面
            startRealPersonAuth();
        } else if (viewId == R.id.card_face_compare) {
            // 跳转到人脸认证1:1页面
            startFaceCompare();
        }
    }
    
    /**
     * 启动活体检测
     */
    private void startLivingDetect() {
        Intent intent = new Intent(this, LivingActivity.class);
        startActivity(intent);
    }
    
    /**
     * 启动实人认证
     * TODO: 实现实人认证功能
     */
    private void startRealPersonAuth() {
        Intent intent = new Intent(this, RealPersonActivity.class);
        startActivity(intent);
    }
    
    /**
     * 启动人脸认证1:1
     * TODO: 实现人脸认证1:1功能
     */
    private void startFaceCompare() {
        Toast.makeText(this, R.string.feature_coming_soon, Toast.LENGTH_SHORT).show();
        // 未来实现：
        // Intent intent = new Intent(this, FaceCompareActivity.class);
        // startActivity(intent);
    }
}

